package com.treasure.mall.zbqmallapi.vo.life;

import com.treasure.mall.biz.entity.embeddable.ReceivingInfo;
import com.treasure.mall.biz.vo.life.ShopBusinessVO;
import com.treasure.mall.zbq.common.StringUtilsExt;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 *
 * <p>
 * +---------------------------------------------------------
 * * @package: com.treasure.mall.zbqmallapi.vo.life
 * * @author: guomw (guomwchen@foxmail.com)
 * * @date: 2020/10/15 11:44 上午
 * * @since: V1.0.0
 * +---------------------------------------------------------
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的
 * 
 */
@Data
public class ShopVO {

    private Long id;

    private String title;

    private String logo;

    private List<ShopBusinessVO> businessScopes;

    private List<ShopBusinessVO> businessTags;

    private String businessTagsText;

    private String businessScopesText;

    /**
     * 地址
     */
    private ReceivingInfo shopAddress;
    /**
     * 掌眼服务
     */
    private boolean palmEyeService;
    /**
     * 修复
     */
    private boolean repairService;

    private Long onlineMerchantId;

    public String getBusinessTagsText() {
        String text = "";
        if (palmEyeService) {
            text = "掌眼";
        }
        if (repairService) {
            if (StringUtils.isNotBlank(text)) {
                text = text + "、修复";
            } else {
                text = "修复";
            }
        }
        String s = strText(this.businessTags);
        if (!StringUtilsExt.isEmpty(text)) {
            return text + "、" + s;
        }
        return s;
    }

    public String getBusinessScopesText() {
        return strText(this.businessScopes);
    }

    /**
     * 经营范围
     *
     * @return
     */
    private String strText(List<ShopBusinessVO> list) {
        StringBuilder str = new StringBuilder();
        if (list != null && list.size() > 0) {
            list.forEach(v -> {
                str.append(v.getTitle()).append(" ");
            });
        }
        return str.toString().trim().replaceAll(" ", "、");
    }

}
